#pragma once

#include <opencv2\opencv.hpp>

using namespace cv;

class KNN
{
private:
	CvKNearest knn;
	int k;

public:
	KNN(int _k)
	{
		k = _k;
	}

	void set_trainer(CvKNearest _knn)
	{
		knn = _knn;
	}

	void train(Mat& data, Mat& label, CvKNearest params)
	{
		knn.train(data, label, Mat(), false, k);
	}

	CvKNearest get_trainer()
	{
		return knn;
	}

	float predict(const Mat& sample)
	{
		return knn.find_nearest(sample, k);
	}
};